﻿using DevExpress.XtraGrid.Demos.util;
using DiaoPaiDaYin;
using DXApplicationTangche.DTO;
using DXApplicationTangche.UC.下单MTO.Service;
using DXApplicationTangche.UC.客户CRM.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace mendian
{
    public partial class Frm客户 : DevExpress.XtraBars.ToolbarForm.ToolbarForm
    {
        public static int cUSTOMER_ID { get; set; }
        public String sEX_CD;
        public String sexno;
        //public int cUSTOMER_FIT_ID;
        public static int aDDRESS_ID;
        public static String customer_name { get; set; }
        public static int customer_countid { get; set; }
        public String SHOP_ID { get; set; }
        public Frm客户(String shopid)
        {
            this.SHOP_ID = shopid;
            InitializeComponent();
            initCombobox();
        }
        public Frm客户(int customerId)
        {

        }
        private void initCombobox()
        {
            this.shengfen.DataSource = null;
            try
            {
                List<AreaDetailDTO> areaDetailDTOs省份 = MTO订单Service.getAreaDetail("7");
                this.shengfen.DataSource = areaDetailDTOs省份;
                this.shengfen.DisplayMember = "name";
            }
            catch { }
        }

        /// <summary>
        /// 将新建客户未填项设为0
        /// </summary>
        /// <param name="cc"></param>
        private void customerZero()
        {
            this.jiankuan.Text = this.jiankuan.Text.Trim() == "" ? "0" : this.jiankuan.Text;
            this.yaowei.Text = this.yaowei.Text.Trim() == "" ? "0" : this.yaowei.Text;
            this.tunwei.Text = this.tunwei.Text.Trim() == "" ? "0" : this.tunwei.Text;
            this.shenchang.Text = this.shenchang.Text.Trim() == "" ? "0" : this.shenchang.Text;
            this.lingwei.Text = this.lingwei.Text.Trim() == "" ? "0" : this.lingwei.Text;
            this.wanwei.Text = this.wanwei.Text.Trim() == "" ? "0" : this.wanwei.Text;
            this.xiuchang.Text = this.xiuchang.Text.Trim() == "" ? "0" : this.xiuchang.Text;
            this.shangbixiufei.Text = this.shangbixiufei.Text.Trim() == "" ? "0" : this.shangbixiufei.Text;
            this.xiongwei.Text = this.xiongwei.Text.Trim() == "" ? "0" : this.xiongwei.Text;

            this.shengao.Text = this.shengao.Text.Trim() == "" ? "0" : this.shengao.Text;
            this.tizhong.Text = this.tizhong.Text.Trim() == "" ? "0" : this.tizhong.Text;
            this.tixing.Text = this.tixing.Text.Trim() == "" ? "0" : this.tixing.Text;
            this.jianxing.Text = this.jianxing.Text.Trim() == "" ? "0" : this.jianxing.Text;
            if (String.IsNullOrWhiteSpace(this.nianling.Text.Trim()))
            {
                this.nianling.Text = "0";
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            #region 原来sql文保存
            //            this.customerZero();
            //            customer_name = this.xing.Text + this.ming.Text;
            //            if (this.sex.Text == "男")
            //            {
            //                sEX_CD = "SEX-M_10";
            //                sexno = "0";
            //            }
            //            else
            //            {
            //                sEX_CD = "SEX-W_20";
            //                sexno = "1";
            //            }
            //            DataRow dr_customerid = SQLmtm.GetDataRow("SELECT MAX(CUSTOMER_ID) AS CUSTOMER_ID FROM a_customer_p ");
            //            cUSTOMER_ID = Convert.ToInt32(dr_customerid["CUSTOMER_ID"]);
            //            cUSTOMER_ID++;
            //            int i1 = SQLmtm.DoInsert("a_customer_p", new string[] { "CUSTOMER_ID", "CUSTOMER_FIRST_NAME", "CUSTOMER_LAST_NAME", "MOBILE", "DEFAULT_ADDR_FLAG", "SEX_CD", "E_MAIL_URL", "DELETE_FLAG", "VERSION", "CUSTOMER_STATUS" },
            //            new string[] { cUSTOMER_ID.ToString(), this.xing.Text, this.ming.Text, this.shouji.Text, "0", sEX_CD, this.eml.Text, "0", "1", "CUSTOMER_SOURCE-CS_SHOP" });
            //            if (i1 != 1)
            //            {
            //                MessageBox.Show("保存失败");
            //            }
            //            //a_customer_fit_count_r           
            //            String sqlacfcr = "INSERT INTO `a_customer_fit_count_r`( `CUSTOMER_ID`, `CUSTOMER_NAME`, `SEX`, `AGE`, `CREATE_DATE`, `DELETE_FLAG`, `DEFAULT_FLAG`, `DATA_COMPLETE`) " +
            //                "VALUES " +
            //                "(" + cUSTOMER_ID.ToString() + ", '" + customer_name + "', '" + sexno + "', '" + this.nianling.Text + "', '" + DateTime.Now.ToUniversalTime().ToString() + "', 0, 1, 1);";
            //            SQLmtm.ExecuteSql(sqlacfcr);
            //            DataRow dr_customer_countid = SQLmtm.GetDataRow("SELECT MAX(ID) AS ID FROM a_customer_fit_count_r");
            //            customer_countid = Convert.ToInt32(dr_customer_countid["ID"]);
            //            //门店客户表
            //            int i2 = SQLmtm.DoInsert("a_shop_customer_r", new string[] { "SHOP_ID", "CUSTOMER_ID" }, new string[] { this.SHOP_ID, cUSTOMER_ID.ToString() });
            //            if (i2 != 1)
            //            {
            //                MessageBox.Show("保存失败");
            //            }
            //            //身高
            //            int i3 = SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //                new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_ITEM_09", "0", this.shengao.Text, customer_countid.ToString() });
            //            if (i3 != 1)
            //            {
            //                MessageBox.Show("保存失败");
            //            }
            //            //体重
            //            int i4 = SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //                    new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_ITEM_10", "0", this.tizhong.Text, customer_countid.ToString() });
            //            //cUSTOMER_FIT_ID++;
            //            if (i4 != 1)
            //            {
            //                MessageBox.Show("保存失败");
            //            }
            //            //肩宽CODE
            //            int i5 = SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //        new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_ITEM_05", "0", this.jiankuan.Text, customer_countid.ToString() });
            //            //cUSTOMER_FIT_ID++;
            //            if (i5 != 1)
            //            {
            //                MessageBox.Show("保存失败");
            //            }
            //            //胸围CODE
            //            int i6 = SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //        new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_ITEM_02", "0", this.xiongwei.Text, customer_countid.ToString() });
            //            //cUSTOMER_FIT_ID++;
            //            if (i6 != 1)
            //            {
            //                MessageBox.Show("保存失败");
            //            }
            //            //腰围CODE
            //            int i7 = SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //        new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_ITEM_12", "0", this.yaowei.Text, customer_countid.ToString() });
            //            //cUSTOMER_FIT_ID++;
            //            if (i7 != 1)
            //            {
            //                MessageBox.Show("保存失败");
            //            }
            //            //臀围CODE
            //            int i8 = SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //        new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_ITEM_03", "0", this.tunwei.Text, customer_countid.ToString() });
            //            //cUSTOMER_FIT_ID++;
            //            if (i8 != 1)
            //            {
            //                MessageBox.Show("保存失败");
            //            }
            //            //身长CODE
            //            int i9 = SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //        new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_ITEM_04", "0", this.shenchang.Text, customer_countid.ToString() });
            //            //cUSTOMER_FIT_ID++;
            //            if (i9 != 1)
            //            {
            //                MessageBox.Show("保存失败");
            //            }
            //            //领围CODE
            //            int i10 = SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //        new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_ITEM_01", "0", this.lingwei.Text, customer_countid.ToString() });
            //            //cUSTOMER_FIT_ID++;
            //            if (i10 != 1)
            //            {
            //                MessageBox.Show("保存失败");
            //            }
            //            //腕围CODE
            //            int i11 = SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //        new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_ITEM_08", "0", this.wanwei.Text, customer_countid.ToString() });
            //            //cUSTOMER_FIT_ID++;
            //            if (i11 != 1)
            //            {
            //                MessageBox.Show("保存失败");
            //            }
            //            //袖长CODE
            //            int i12 = SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //        new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_ITEM_06", "0", this.xiuchang.Text, customer_countid.ToString() });
            //            //cUSTOMER_FIT_ID++;
            //            if (i12 != 1)
            //            {
            //                MessageBox.Show("保存失败");
            //            }
            //            //上臂袖肥CODE
            //            int i13 = SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //        new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_ITEM_07", "0", this.shangbixiufei.Text, customer_countid.ToString() });
            //            //cUSTOMER_FIT_ID++;
            //            if (i13 != 1)
            //            {
            //                MessageBox.Show("保存失败");
            //            }
            //            //体型CODE
            //            switch (this.tixing.Text)
            //            {
            //                case "正常":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_03", "0", "CD03_07", customer_countid.ToString() }); break;
            //                case "中肚":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_03", "0", "CD03_08", customer_countid.ToString() }); break;
            //                case "大肚":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_03", "0", "CD03_09", customer_countid.ToString() }); break;
            //                case "后腰空":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_03", "0", "CD03_10", customer_countid.ToString() }); break;
            //            }
            //            //cUSTOMER_FIT_ID++;
            //            //喜好CODE
            //            switch (this.xihao.Text)
            //            {
            //                case "标准":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_08", "0", "CD08_01", customer_countid.ToString() }); break;
            //                case "超修":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_08", "0", "CD08_02", customer_countid.ToString() }); break;
            //                case "宽松":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_08", "0", "CD08_03", customer_countid.ToString() }); break;
            //            }
            //            //cUSTOMER_FIT_ID++;
            //            //肩型
            //            switch (this.jianxing.Text)
            //            {
            //                case "平肩":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //            new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_01", "0", "1", customer_countid.ToString() }); break;
            //                case "溜肩":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //            new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_01", "0", "2", customer_countid.ToString() }); break;
            //                case "正常":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //            new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_01", "0", "3", customer_countid.ToString() }); break;
            //                case "冲肩":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //            new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_01", "0", "4", customer_countid.ToString() }); break;
            //            }
            //            //胸型
            //            switch (this.xiongxing.Text)
            //            {
            //                case "正常":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_09", "0", "CD09_01", customer_countid.ToString() }); break;
            //                case "驼背":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_09", "0", "CD09_02", customer_countid.ToString() }); break;
            //                case "挺胸":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_09", "0", "CD09_03", customer_countid.ToString() }); break;
            //                case "丰满胸":
            //                    SQLmtm.DoInsert("a_customer_fit_r", new string[] { "CUSTOMER_ID", "STYLE_CATEGORY_CD", "ITEM_CD", "ITEM_VALUE", "DELETE_FLAG", "FIT_VALUE", "FIT_COUNT_ID" },
            //new string[] { cUSTOMER_ID.ToString(), "STYLE_CATEGORY-SHIRT", "SHIRT_FITMT004", "FITMT_CODE_09", "0", "CD09_04", customer_countid.ToString() }); break;

            //            }
            //            DataRow dr_addressid = SQLmtm.GetDataRow("SELECT MAX(ADDRESS_ID) AS ADDRESS_ID FROM a_customer_address_p");
            //            aDDRESS_ID = Convert.ToInt32(dr_addressid["ADDRESS_ID"]);
            //            aDDRESS_ID++;
            //            if (String.IsNullOrEmpty(this.shouhuoren.Text))
            //            {
            //                this.shouhuoren.Text = customer_name;
            //            }
            //            SQLmtm.DoInsert("a_customer_address_p", new string[] { "ADDRESS_ID", "CUSTOMER_ID", "DEFAULT_ADDR_FLAG", "CONSIGNEE", "ADDRESS_PROVINCE_CD", "ADDRESS_CITY_CD", "ADDRESS_DISTRICT", "ADDRESS_DETAIL", "ZIP_CODE", "MOBILE", "DELETE_FLAG" },
            //                new string[] { aDDRESS_ID.ToString(), cUSTOMER_ID.ToString(), "1", this.shouhuoren.Text, this.shengfen.Text, this.chengshi.Text, this.qvyv.Text, this.xiangxidizhi.Text, this.youbian.Text, this.shoujianshouji.Text, "0" });
            //            String listFitData = null;
            //            try
            //            {
            //                DataTable dt = SQLmtm.GetDataTable("SELECT CUSTOMER_ID,ITEM_CD,ITEM_VALUE,FIT_VALUE FROM `a_customer_fit_r` WHERE FIT_COUNT_ID='" + customer_countid.ToString() + "'");
            //                foreach (DataRow dr in dt.Rows)
            //                {
            //                    listFitData = listFitData + dr["ITEM_CD"].ToString() + "-" + dr["ITEM_VALUE"].ToString() + ":" + dr["FIT_VALUE"] + ",";
            //                }
            //            }
            //            catch
            //            {
            //                MessageBox.Show("保存失败");
            //                return;
            //            }
            //            FitValueCalculate fvc = new FitValueCalculate(customer_countid.ToString(), listFitData);

            //            String fjsondata = Newtonsoft.Json.JsonConvert.SerializeObject(fvc);
            //            RestCall.PostHttp(URL.接口url + "/size/updateCalculate", fjsondata);
            //            MessageBox.Show("保存成功");
            //            this.Close();
            #endregion
            if (
                //  客户
                String.IsNullOrWhiteSpace(this.xing.Text)
                || String.IsNullOrWhiteSpace(this.ming.Text)
                || String.IsNullOrWhiteSpace(this.shouji.Text)
                || String.IsNullOrWhiteSpace(this.sex.Text)
                //  收货
                || String.IsNullOrWhiteSpace(this.shouhuoren.Text)
                || String.IsNullOrWhiteSpace(this.shoujianshouji.Text)
                || String.IsNullOrWhiteSpace(this.xiangxidizhi.Text)
                 || String.IsNullOrWhiteSpace(this.youbian.Text)
                //  体型、喜好、肩型、胸型
                || String.IsNullOrWhiteSpace(this.tixing.Text)
                || String.IsNullOrWhiteSpace(this.xihao.Text)
                || String.IsNullOrWhiteSpace(this.jianxing.Text)
                || String.IsNullOrWhiteSpace(this.xiongxing.Text)
                )
            {
                MessageBox.Show("请将*号内容填写完整");
                return;
            }
            Dictionary<String, String> itemValueAndFitValueMap = new Dictionary<string, string>();
            #region 量体
            ////身高
            //if (!String.IsNullOrWhiteSpace(this.shengao.Text))
            //{
            //    itemValueAndFitValueMap.Add("FITMT_ITEM_09", this.shengao.Text.Trim());
            //}
            ////体重
            //if (!String.IsNullOrWhiteSpace(this.tizhong.Text))
            //{
            //    itemValueAndFitValueMap.Add("FITMT_ITEM_10", this.tizhong.Text.Trim());
            //}
            ////肩宽CODE
            //if (!String.IsNullOrWhiteSpace(this.jiankuan.Text))
            //{
            //    itemValueAndFitValueMap.Add("FITMT_ITEM_05", this.jiankuan.Text.Trim());
            //}
            ////胸围CODE
            //if (!String.IsNullOrWhiteSpace(this.xiongwei.Text))
            //{
            //    itemValueAndFitValueMap.Add("FITMT_ITEM_02", this.xiongwei.Text.Trim());
            //}
            ////腰围CODE
            //if (!String.IsNullOrWhiteSpace(this.yaowei.Text))
            //{
            //    itemValueAndFitValueMap.Add("FITMT_ITEM_12", this.yaowei.Text.Trim());
            //}
            ////臀围CODE
            //if (!String.IsNullOrWhiteSpace(this.tunwei.Text))
            //{
            //    itemValueAndFitValueMap.Add("FITMT_ITEM_03", this.tunwei.Text.Trim());
            //}
            ////身长CODE
            //if (!String.IsNullOrWhiteSpace(this.shenchang.Text))
            //{
            //    itemValueAndFitValueMap.Add("FITMT_ITEM_04", this.shenchang.Text.Trim());
            //}
            ////领围CODE
            //if (!String.IsNullOrWhiteSpace(this.lingwei.Text))
            //{
            //    itemValueAndFitValueMap.Add("FITMT_ITEM_01", this.lingwei.Text.Trim());
            //}
            ////腕围CODE
            //if (!String.IsNullOrWhiteSpace(this.wanwei.Text))
            //{
            //    itemValueAndFitValueMap.Add("FITMT_ITEM_08", this.wanwei.Text.Trim());
            //}
            ////袖长CODE
            //if (!String.IsNullOrWhiteSpace(this.xiuchang.Text))
            //{
            //    itemValueAndFitValueMap.Add("FITMT_ITEM_06", this.xiuchang.Text.Trim());
            //}
            ////上臂袖肥CODE
            //if (!String.IsNullOrWhiteSpace(this.shangbixiufei.Text))
            //{
            //    itemValueAndFitValueMap.Add("FITMT_ITEM_07", this.shangbixiufei.Text.Trim());
            //}
            #endregion
            //体型CODE
            switch (this.tixing.Text)
            {
                case "正常":
                    itemValueAndFitValueMap.Add("FITMT_CODE_03", "CD03_07");
                    break;
                case "中肚":
                    itemValueAndFitValueMap.Add("FITMT_CODE_03", "CD03_08");
                    break;
                case "大肚":
                    itemValueAndFitValueMap.Add("FITMT_CODE_03", "CD03_09");
                    break;
                case "后腰空":
                    itemValueAndFitValueMap.Add("FITMT_CODE_03", "CD03_10");
                    break;
            }
            //喜好CODE
            switch (this.xihao.Text)
            {
                case "标准":
                    itemValueAndFitValueMap.Add("FITMT_CODE_08", "CD08_01");
                    break;
                case "超修":
                    itemValueAndFitValueMap.Add("FITMT_CODE_08", "CD08_02");
                    break;
                case "宽松":
                    itemValueAndFitValueMap.Add("FITMT_CODE_08", "CD08_03");
                    break;
            }
            //肩型
            switch (this.jianxing.Text)
            {
                case "平肩":
                    itemValueAndFitValueMap.Add("FITMT_CODE_01", "1");
                    break;
                case "溜肩":
                    itemValueAndFitValueMap.Add("FITMT_CODE_01", "2");
                    break;
                case "正常":
                    itemValueAndFitValueMap.Add("FITMT_CODE_01", "3");
                    break;
                case "冲肩":
                    itemValueAndFitValueMap.Add("FITMT_CODE_01", "4");
                    break;
            }
            //胸型
            switch (this.xiongxing.Text)
            {
                case "正常":
                    itemValueAndFitValueMap.Add("FITMT_CODE_09", "CD09_01");
                    break;
                case "驼背":
                    itemValueAndFitValueMap.Add("FITMT_CODE_09", "CD09_02");
                    break;
                case "挺胸":
                    itemValueAndFitValueMap.Add("FITMT_CODE_09", "CD09_03");
                    break;
                case "丰满胸":
                    itemValueAndFitValueMap.Add("FITMT_CODE_09", "CD09_04");
                    break;
            }
            if (this.sex.Text == "男")
            {
                sEX_CD = "SEX-M_10";
                sexno = "0";
            }
            else
            {
                sEX_CD = "SEX-W_20";
                sexno = "1";
            }
            CustomerInfoCreateDTO customerInfoCreateDTO =
                new CustomerInfoCreateDTO(
                    this.xing.Text,
                    this.ming.Text,
                    this.shouji.Text,
                    1,
                    sEX_CD,
                    this.eml.Text,
                    "",
                    sexno,
                    itemValueAndFitValueMap,
                    new CustomerAddressInfoDTO(
                            this.shouhuoren.Text,
                            this.shengfen.Text,
                            this.chengshi.Text,
                            this.qvyv.Text,
                            this.xiangxidizhi.Text,
                            this.youbian.Text,
                            this.shoujianshouji.Text
                        ),
                    new SimpleDropDownDTO(this.SHOP_ID)
                    );
            FunctionHelper.JsonSerialization(customerInfoCreateDTO);
            try
            {
                CRM客户Service.createCustomerInfo(customerInfoCreateDTO);
                MessageBox.Show("保存成功");
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败");
                return;
            }
        }

        private void shengfen_TextChanged(object sender, EventArgs e)
        {
            this.chengshi.DataSource = null;
            this.qvyv.DataSource = null;
            try
            {
                AreaDetailDTO dto省份 = this.shengfen.SelectedItem as AreaDetailDTO;
                List<AreaDetailDTO> areaDetailDTOs城市 = MTO订单Service.getAreaDetail(dto省份.areaId);
                this.chengshi.DataSource = areaDetailDTOs城市;
                this.chengshi.DisplayMember = "name";
            }
            catch { }
        }

        private void chengshi_TextChanged(object sender, EventArgs e)
        {
            this.qvyv.DataSource = null;
            try
            {
                AreaDetailDTO dto城市 = this.chengshi.SelectedItem as AreaDetailDTO;
                List<AreaDetailDTO> areaDetailDTOs县区 = MTO订单Service.getAreaDetail(dto城市.areaId);
                this.qvyv.DataSource = areaDetailDTOs县区;
                this.qvyv.DisplayMember = "name";
            }
            catch { }
        }

        
    }
}
